package com.atguigu.tingshu.account.api;

import com.atguigu.tingshu.account.service.RechargeInfoService;
import com.atguigu.tingshu.common.anno.AuthLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.RechargeInfoVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Tag(name = "充值管理")
@RestController
@RequestMapping("api/account/rechargeInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class RechargeInfoApiController {

	@Autowired
	private RechargeInfoService rechargeInfoService;
// 	api/account/rechargeInfo/submitRecharge
	@AuthLogin
	@PostMapping("submitRecharge")
	public Result<Map<String , String>> submitRecharge(@RequestBody RechargeInfoVo rechargeInfoVo){
		Map<String,String> map = new HashMap<>();
		map.put("orderNo",rechargeInfoService.submitRecharge(rechargeInfoVo));
		return Result.ok(map);
	}

	@GetMapping("/getByOrderNo/{orderNo}")
	public Result<RechargeInfo> getByOrderNo(@PathVariable String orderNo){
		return Result.ok(rechargeInfoService.getByOrderNo(orderNo));
	}

}

